using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;


namespace HelloXNA2.Component.MyCustom.Mouse
{
    /// <summary>
    /// This is a game component that implements IUpdateable.
    /// </summary>
    public class Demo : Microsoft.Xna.Framework.DrawableGameComponent
    {
        Texture2D _sprite;
        SpriteBatch _spriteBatch;
        public Demo(Game game)
            : base(game)
        {
            // TODO: Construct any child components here
        }

        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            // TODO: Add your initialization code here
            Game.IsMouseVisible = true;
            base.Initialize();
        }

        protected override void LoadContent()
        {
            _spriteBatch = new SpriteBatch(Game.GraphicsDevice);
            //_sprite = Game.Content.Load<Texture2D>("Image/Son");

            _sprite = new Texture2D(GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
            Color[] pixels = new Color[1];
            pixels[0] = Color.White;

            _sprite.SetData<Color>(pixels);
        }

        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            // TODO: Add your update code here

            base.Update(gameTime);
        }

        int i = 0;
        public override void Draw(GameTime gameTime)
        {
            Game.GraphicsDevice.Clear(Color.CornflowerBlue);

            _spriteBatch.Begin();


            //public void Draw(Texture2D texture, Rectangle destinationRectangle, Rectangle? sourceRectangle, Color color, float rotation, Vector2 origin, SpriteEffects effects, float layerDepth);


            //_spriteBatch.Draw(_sprite, new Rectangle(200, 200, 1, 100), null, Color.White, MathHelper.PiOver4 * i, Vector2.Zero, SpriteEffects.None, 0);

            MouseState mouseState = Microsoft.Xna.Framework.Input.Mouse.GetState();

            drawLineHelper helper = new drawLineHelper(this.GraphicsDevice);
            helper.CreateLine(new Vector2((float)(Game.Window.ClientBounds.Width / 2), (float)(Game.Window.ClientBounds.Height)), new Vector2(mouseState.X, mouseState.Y), 100);
            helper.Render(_spriteBatch);

            _spriteBatch.End();

            base.Draw(gameTime);
        }
    }
}
